Skip to main content

number

Type

function

Summary

Returns the number of objects of a certain kind, or the number of chunks in a string.

Syntax

the number of [{card|cd|background|bkgnd|bg}] {<objectType> | parts | controls}
the number of {<objectType> | parts | controls} [{in | of} <groupRef>]
the number of {backgrounds | groups} [ [{in | of} <cardRef>] {in | of} <stackRef>]
the number of [marked] cards [{in | of} <stackRef>]
the number of {char[acters] | items | words | lines} {in | of} <textString>
the number of elements {in | of} <arrayExpr>

Description

Use the number function to find out how many of a thing there are.

If you use the form the number of card controls, the number function returns the number of controls on the current card that are not members of a group. The form the number of background controls returns the number of grouped controls that are in a group whose backgroundBehavior property is set to true.

The expression

    the number of chars in &lt;textString&gt;

is equivalent to:

    the length of &lt;textString&gt;

The expression

    the number of backgrounds of &lt;stackRef&gt;

returns the number of groups in the stack.

The expression

    the number of groups of &lt;stackRef&gt;

returns the number of groups on the current card of the stack. Groups that are nested inside another group are not counted.

note

The number is implemented as a read-only global property, but can be more conveniently thought of as a function.

Parameters

NameTypeDescription

objectType

enum

groupRef

A reference to any group in the current stack.

cardRef

A reference to any card in the current stack.

stackRef

Any stack reference.

textString

string

Any string or expression that evaluates to a string.

arrayExpr

array

Any array or expression that evaluates to an array.

Examples

repeat for the number of words in inputString
if the number of card buttons &gt; 0 then doTheButtons

command: global, group

control structure: function

function: length

glossary: property, current card, return, group, nest, chunk, read-only, expression, non-negative, object

keyword: string, control, integer

object: stack

property: backgroundBehavior, layer

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?